#ifndef DELETEBUTTONDELEGATE_H
#define DELETEBUTTONDELEGATE_H

#include <QWidget>
#include <QObject>

#include <QStyledItemDelegate>
#include <QPushButton>
#include <QTableView>
#include <QModelIndex>

class DeleteButtonDelegate : public QStyledItemDelegate {
    Q_OBJECT
public:
    explicit DeleteButtonDelegate(QObject *parent = nullptr);

    // 创建QPushButton作为持久化编辑器
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override;

    // 更新按钮位置
    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
                              const QModelIndex &index) const override;

signals:
    void deleteRowRequested(int row) const; // 删除行信号
};

#endif // DELETEBUTTONDELEGATE_H
